package com.bingo.datasecurity.controller;

import com.bingo.datasecurity.entity.po.UserPo;
import com.bingo.datasecurity.service.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author bingo
 * @date 2024/2/6 11:37
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;


    /**
     * 添加一个用户
     *
     * @param userPo
     */
    @PostMapping("addUser")
    public String addUser(UserPo userPo) {
        userService.addUser(userPo);
        return "ok";
    }


    /**
     * 批量添加用户
     *
     * @param userPoList
     */
    @PostMapping("addBatchUser")
    public String addBatchUser(@RequestBody List<UserPo> userPoList) {
        userService.addBatchUser(userPoList);
        return "ok";
    }


    /**
     * 查询所有用户
     *
     * @return
     */
    @PostMapping("queryAllUser")
    public List<UserPo> queryAllUser() {
        return userService.queryAllUser();
    }
}
